import Vue from 'vue'
import Vuex from 'vuex'
//持久化
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    text: [],
    yestext: [],
    qxtext: []
  },
  mutations: {
    //添加内容
    add(state, title) {
      state.text.push(title)
    },
    //点击未完成列表的单选变成已完成
    goYes(state, index) {
      state.yestext.push(state.text[index])
      state.text.splice(index, 1)
    },
    //点击已完成列表的单选变成未完成
    goNo(state, index) {
      state.text.push(state.yestext[index])
      state.yestext.splice(index, 1)
    },
    ////点击未完成列表的单选变成取消
    goQx(state, index) {
      state.qxtext.push(state.text[index])
      state.text.splice(index, 1)
    },
    goNo2(state, index) {
      state.text.push(state.qxtext[index])
      state.qxtext.splice(index, 1)
    },
  },
  actions: {
  },
  modules: {
  },
  //持久化
  plugins: [createPersistedState()]
})
